package com.example.service.impl;

import com.example.entity.Goods;
import com.example.mapper.ProductMapper;
import com.example.service.IProductService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

/**
 * 本类用来演示:
 *
 * @author: success
 * @date: 2020/12/25 2:14 下午
 */
@Service
public class ProductServiceImpl implements IProductService {

    @Autowired
    private ProductMapper productMapper;

    @Override
    public PageInfo<Goods> findAll(String name, Integer typeId, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);

        List<Goods> list = productMapper.findAll(name,typeId);

        PageInfo<Goods> pageInfo = new PageInfo<>(list);

        return pageInfo;
    }

    @Override
    public Goods findOneByProductId(Integer  goodsId) {
        return productMapper.findOneByProductId( goodsId);
    }

    @Override
    public List<Goods> findUserGoods(Integer id) {
        List<Goods>UserGoods = productMapper.findUserGoods(id);
        return UserGoods;
    }

}
